<?php

namespace app\admin\service;

use app\admin\model\UM as UM;
use ShidianUtil\Exception\DataNotExistException;
use app\admin\dao\MemberDao;
use app\common\model\Member;
use ShidianUtil\Utils\TimeUtil;
use think\Collection;

/**
 * Class MemberInvitedService
 * @package app\admin\service
 */
class MemberInvitedService
{
    // dao
    private MemberDao $memberDao;

    public function __construct(MemberDao $memberDao)
    {
        $this->memberDao = $memberDao;
    }

    /**
     * @param UM|null $user
     * @param $channel
     * @param $provinceId
     * @param $cityId
     * @param $startTime
     * @param $endTime
     * @param $kw
     * @param $inviteId
     * @param int|null $page
     * @param int|null $page_size
     * @return array
     */
    public function index(?UM $user, $channel, $provinceId, $cityId, $startTime, $endTime, $kw, $inviteId, ?int $page = null, ?int $page_size = null): array
    {
        if(is_numeric($endTime)){
            $endTime = TimeUtil::stamp(TimeUtil::DAY, $endTime, false);
        }

        return $this->memberDao->listMembersInvited($channel, $provinceId, $cityId, $startTime, $endTime, $kw, $inviteId, $page, $page_size);
    }

}
